package dyyx.util;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;

import dyyx.dto.DubboServiceInfo;
import dyyx.dto.NodeData;
import dyyx.dto.WebResult;

public abstract class DubboViewWebUtil {
	
	
	public static void listAllService(HttpServletRequest request, WebResult webResult){
		
		try{
			//
		    List<NodeData> list = DubboUtil.getAllServices();
		    webResult.list = list;
		
		}catch(Throwable e){
			webResult.msg = "listAllService error,"+e;
		}
		
		
	}
	
    public static void getServiceInfo(HttpServletRequest request, WebResult webResult){
		
		try{
			String service = WebUtil.get(request, "service");
			if(StringUtils.isBlank(service)){
				webResult.msg = "service blank";
				webResult.error = true;
				return;
			}
			webResult.service = service;
			//
			DubboServiceInfo serviceInfo = DubboUtil.getServiceInfo(service);
			
		    
		    webResult.serviceInfo = serviceInfo;
		
		}catch(Throwable e){
			webResult.msg = "getServiceInfo error,"+e;
			webResult.error = true;

		}
		
		
	}

	

	public static void run(HttpServletRequest request, WebResult webResult) throws Exception {
		try {
			run_(request, webResult);
		} catch (Throwable e) {
			webResult.msg = webResult.op + " error," + e;
		}
	}
	
	

	private static void run_(HttpServletRequest request, WebResult webResult) throws Exception {
		
		
		


	}
	
	

}
